package com.yyfax.pay.third.model.to.fuiou;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.converters.basic.LongConverter;
import com.thoughtworks.xstream.converters.basic.StringConverter;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import org.apache.commons.lang3.StringUtils;

@XStreamAlias("RESPONSE")
public class FuiouProtocolPayQueryRsp {

    @XStreamAlias("VERSION")
    private String version;

    @XStreamAlias("RESPONSECODE")
    private String respCode;

    @XStreamAlias("RESPONSEMSG")
    private String respDesc;

    @XStreamAlias("MCHNTORDERID")
    private String busiId;

    @XStreamAlias("AMT")
    private String amount;

    @XStreamAlias("ORDERDATE")
    private String orderTime;

    @XStreamAlias("BANKCARD")
    private String cardNo;

    @XStreamAlias("SIGN")
    private String sign;

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getRespCode() {
        return respCode;
    }

    public void setRespCode(String respCode) {
        this.respCode = respCode;
    }

    public String getRespDesc() {
        return respDesc;
    }

    public void setRespDesc(String respDesc) {
        this.respDesc = respDesc;
    }

    public String getBusiId() {
        return busiId;
    }

    public void setBusiId(String busiId) {
        this.busiId = busiId;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(String orderTime) {
        this.orderTime = orderTime;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public static FuiouProtocolPayQueryRsp fromXml(String xml) {
        QNameMap qmap = new QNameMap();
        qmap.setDefaultPrefix("");
        StaxDriver staxDriver = new StaxDriver(qmap);
        XStream xstream = new XStream(staxDriver);
        xstream.autodetectAnnotations(true);
        xstream.ignoreUnknownElements();
//        xstream.registerConverter(new LongConverter(){
//            @Override
//            public Object fromString(String str) {
//                if (StringUtils.isBlank(str)) {
//                    return null;
//                }
//                return super.fromString(str);
//            }
//        });
        xstream.alias("RESPONSE", FuiouProtocolPayQueryRsp.class);
        return (FuiouProtocolPayQueryRsp) xstream.fromXML(xml);
    }
}
